<template>
  <div>
    <div class="swiper">
      <van-swipe :autoplay="3000">
        <van-swipe-item v-for="(image, index) in swiper" :key="index">
          <img :src="image.pic" />
        </van-swipe-item>
      </van-swipe>
    </div>
    <div class="barcontain">
      <p class="p1">{{ detail.name }}</p>
      <p class="p2">{{ detail.characteristic }}</p>
      <div class="bar2">
        <p>
          低价<span>￥{{ detail.originalPrice }}</span>
        </p>
        <p>原价￥{{ detail.originalPrice }}</p>
        <p>库存{{ detail.stores }}</p>
      </div>
    </div>
      <div class="tab">
            <p :class="selIndex?'selIndex':''" @click="selIndex = !selIndex;">商品介绍</p>
            <p :class="!selIndex?'selIndex':''" @click="selIndex = !selIndex;">商品评价</p>
        </div>
    <div class="content">
        <div v-html="content"></div>
    </div>
  </div>
</template>
<script>
export default {
  data() {
    return {
      detail: [],
      swiper: [],
      content:[],
      selIndex:true
    };
  },
  methods: {},
  mounted() {
    this.$API
      .getGoodsData({ params: { id: this.$route.query.id } })
      .then((res) => {
        console.log(res);
        this.detail = res.data.data.basicInfo;
        this.swiper = res.data.data.pics;
        this.content=res.data.data.content;
      });
    this.$API.getRequtation({
          params: {
            goodsId: id
          }
        }).then(res=> {
        //   console.log(res.data.data)
          this.requtation = res.data.data;
        })
      
  },
};
</script>
<style lang="scss">
.swiper {
  width: 100%;
  height: 22.5rem;
  // background-color: aqua;
  img {
    width: 100%;
    height: 100%;
  }
}
.barcontain {
  width: 100%;
  height: 7rem;
  background: #ffffff;
  padding-left: 0.2rem;
  border-bottom: 0.14rem solid #f5f5f5;
  .p1 {
    font-size: 0.9rem;
    color: #464646;
    margin-top: 0.3rem;
  }
  .p2 {
    font-size: 0.7rem;
    color: #b8b8b8;
    margin-top: 0.16rem;
  }
}
.bar2 {
  display: flex;
  height: 2rem;
  align-items: center;
  margin-top: 0.1rem;
  p:nth-of-type(1) {
    font-size: 0.5rem;
    color: #cc0c0c;
    width: 4rem;
    span{
        font-size: 0.9rem;
    }
  }
   p:nth-of-type(2){
      font-size: 0.7rem;
    color: #B8B8B8;
    width: 15rem;
   }
   p:nth-of-type(3){
      font-size: 0.7rem;
    color: #B8B8B8;
   }
}
.tab{
    width: 100%;
    display: flex;
    justify-content: space-between;
    p{
        flex: 1;
        text-align: center;
        padding: 10px 10px;
        box-sizing: border-box;
    }
   .selIndex{
        border-bottom: 2px solid red;
    }
}
.content{
    width: 100%;
    img{
        width: 100% !important;
       height: 8em !important;
    }
}
</style>